<div class="easyui-panel" title="班级成绩录入" data-options="fit:true" style="display: flex; flex-direction: column;">
	<p style="flex-flow: 0;">
		<label>选择班级：</label>
		<input id="bj" class="easyui-combobox" data-options="
		             	url:'banji/list',
						valueField:'id',
						textField:'name',
						panelHeight:200,
						editable:false,
						icons:[{
					        iconCls:'icon-clear',
					        handler: function(e){
					       	 $(e.data.target).textbox('clear');
					        	$('#div2').hide();
					        }
					  		  }],
		" />
		<label>选择课程：</label>
		<input id="kc" class="easyui-combobox" data-options="
						url:'course/list',
						valueField:'id',
						textField:'name',
						panelHeight:200,
						editable:false,
						icons:[{
								 iconCls:'icon-clear',
						         handler: function(e){
					       	 	$(e.data.target).textbox('clear');
					        	$('#div2').hide();
								        }
								  	}],
		" />
		<button class="easyui-linkbutton" data-options="iconCls:'icon-search'" id="cx">查询</button>
		<button class="easyui-linkbutton" data-options="
		 iconCls:'icon-reload',
         hadler:function(){
		    var grid=$.crudgrid.grid(this);
		    grid.datagrid('clearSelections');
		  	grid.datagrid('reload');
	  }		
		">刷新</button>
		</p>
		<div id="div2" style="flex-grow: 1; display: none;">
			<table id="bjcj">
				<thead>
					<tr>
						<th data-options="field:'id',hidden:true">ID</th>
						<th width="200" data-options="
						field:'student',
						sortable: true,
						formatter:function(val,row,index){
							return row.student.stuNo;
								}">学号</th>
						<th width="300" data-options="
						field:'name',
						formatter:function(val,row,index){
								return row.student.name;
								}">姓名</th>
						<th width="200" data-options="field:'grade',
						formatter:formatter3">成绩</th>
					</tr>
				</thead>
			</table>
		</div>
</div>
<script type="text/javascript">
$(function(){
	var grid = $('#bjcj');
	$('#cx').bind('click',function(){
		var kcId=$('#kc').combobox('getValue');
		var bjId=$('#bj').combobox('getValue');
		if(bjId==0||kcId==0){
				$('#div2').hide();
				return;
			}else{
				$('#div2').show();
				xgcj1(bjId,kcId);
		}
		grid.datagrid({
			fit: true,
			url: 'grade/page?bjId='+bjId+'&kcId='+kcId,
			singleSelect: true,
			fitColumns: true,
			autoRowHeight: true,
			striped: true,
			idField: 'id',
			sortName: 'id',
			sortOrder: 'asc',
			pageList: [5, 10, 20, 30],
			pagination: true,
		});

	});
	
})
 function formatter3(val, row, index) {   
 	if(row.grade==null){
       row.grade=0;
	 	}
	 		 return '<input id="dd" value="'+row.grade+'"/>';
    }

$("input[id='input']").numberbox({
    min:0,
    precision:0
});
function xgcj1(bjId,kcId){
	$('#bjcj').datagrid($.extend({},$.crudgrid.defaults,{
		url:'grade/page??bjId='+bjId+'&kcId'+kcId,
		onLoadSuccess:function(data){
	            $("input[id='dd']").numberbox({
	            	onChange:function(grade,oldgrade){
		            	var grid=$('#bjcj').datagrid('getSelected');
						xg(grid.id,grade);
		            }
		        });  
	   	}
	}))
};
function xg(id,grade){
	if(!(/^[0-9]\d*$/.test(grade))){
		$.messager.alert('提示','请输入正整数','info');
		return;
	};
$.post('grade/xgcj1',{id:id,grade:grade},function(data){});
}
</script>